package org.ecloud.oauth.server.service.impl;

import java.util.List;

import org.ecloud.oauth.server.config.ClientConfig;
import org.ecloud.oauth.server.entity.ClientVo;
import org.ecloud.oauth.server.mapper.LocalRowMapper;
import org.ecloud.oauth.server.service.BaseService;
import org.ecloud.oauth.server.service.IClientService;
import org.ecloud.utils.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class ClientServiceImpl extends BaseService implements IClientService {

	@Autowired
	private ClientConfig config;
	
	@Override
	public ClientVo getByClientId(String clientId) {
		List<ClientVo> clients = jdbcTemplate.query(config.getSql(), new Object[]{clientId}, new LocalRowMapper<ClientVo>(ClientVo.class));
		
		if(BeanUtil.isNotEmpty(clients)){
			return clients.get(0);
		}
		
		return null;
	}

}
